<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>玻璃宝</title>
<link type="text/css" rel="stylesheet" href="../css/index.css" />
<script src="../js/util/jquery-1.7.2.min.js"></script>

<script language="javascript" src="../js/util/lazyloadv3.js"></script>
<script src="../js/util/md5.js"></script>
<script src="../js/util/sha1.js"></script>
</head>
	<select onchange="getBarndSub($(this).val());" id="brand">

	</select>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<select id="brand-sub" disabled="disabled">
	</select>
	
	<input value="下一步" type="button" onclick="stepNext();"/>
	<script type="text/javascript">
		var brandsJson = ${brandsJson}
		function  getBarndSub(id){
			if(id != -1){
				var brandSub = $('#brand-sub');
				brandSub.removeAttr('disabled');
				brandSub.children('option').remove();
				for(var i = 0 ; i < brandsJson.length ;i++){
					var pid = brandsJson[i].pid;
					if(pid == id){
						brandSub.append('<option value="'+brandsJson[i].id+'">'+brandsJson[i].name+'</option>');
					}
				}
			}
		}
		
		function initBrand(){
			var brand = $('#brand');
			for(var i = 0 ; i < brandsJson.length ;i++){
				var pid = brandsJson[i].pid;
				if(pid == 0){
					brand.append('<option value="'+brandsJson[i].id+'">'+brandsJson[i].name+'</option>');
				}
			}
			
			var defBrandId = brand.children('option:first').val();
			getBarndSub(defBrandId);
		}
		
		function stepNext(){
			console.log($('#brand').val());
			console.log($('#brand-sub').val());
		}
		initBrand();
	</script>
</body>
</html>